package com.dxc.intern.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dxc.intern.entity.Roster;
import com.dxc.intern.mapper.RosterMapper;
import com.dxc.intern.service.RosterService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 花名册(已入职) 服务实现类
 * </p>
 *
 * @author zhangchengming
 * @since 2022-02-21
 */
@Service
public class RosterServiceImpl extends ServiceImpl<RosterMapper, Roster> implements RosterService {

    @Autowired
    private RosterMapper rosterMapper;

    @Override
    public IPage<Roster> selectPage(Integer pageNo, Integer pageSize, String name, String phone, String postion, String education, String school, String addr) {
        LambdaQueryWrapper<Roster> query= Wrappers.<Roster>lambdaQuery();
        query.like(StringUtils.isNotBlank(name),Roster::getName,name);
        query.like(StringUtils.isNotBlank(phone),Roster::getPhone,phone);
        query.like(StringUtils.isNotBlank(school),Roster::getSchool,school);
        query.like(StringUtils.isNotBlank(education),Roster::getEducation,education);
        query.like(StringUtils.isNotBlank(postion),Roster::getPostion,postion);
        query.like(StringUtils.isNotBlank(addr),Roster::getPostion,addr);
        IPage<Roster> page=rosterMapper.selectPage(new Page<>(pageNo,pageSize),query);
        return page;
    }
}
